export default {
  methods: {
    getElInput (h, args) {
      const {
        row,
        index,
        key,
        size,
        disabled,
        placeholder,
        isShowWordLimit,
        maxlength,
        changeRunFn = () => {},
        inputRunFn = () => {},
        blurRunFn = () => {}
      } = args;
      return <el-input
        vModel_trim={ row[key] }
        disabled={ disabled }
        size={ size }
        placeholder={ placeholder }
        show-word-limit={ isShowWordLimit }
        maxlength={ maxlength }
        onInput={ () => { inputRunFn({ val: row[key], index, key }) } }
        onChange={ () => { changeRunFn({ val: row[key], index, key }) } }
        onBlur={ () => { blurRunFn({ val: row[key], index, key }) } }
      ></el-input>
    },
    getElSelect (h, args) {
      const {
        row,
        index,
        key,
        size,
        clearable,
        options,
        changeRunFn = () => {},
        optionValKey = 'value',
        optionLabelKey = 'label',
        disabled = false
      } = args;
      return <el-select
        v-model={ row[key] }
        placeholder="请选择"
        disabled={ disabled }
        size={ size }
        clearable={ clearable }
        onChange={() => { changeRunFn({ val: row[key], index }) }}
      >
        { options.map(item => {
          return <el-option
            key={item[optionValKey]}
            label={item[optionLabelKey]}
            value={item[optionValKey]}
          ></el-option>
        }) }
      </el-select>
    }
  }
}
